public with sharing class AccountListAuraController {
    public AccountListAuraController() {

    }
  
    @AuraEnabled
    public static Map<String, Object> getAccounts(String searchKeyWord, Integer currentPage, Integer pageSize){
        Map<String, Object> resMap = new Map<String, Object>();
        try {
            List<Account> accList = null;
            // 查询符合条件的数据
            accList = new List<Account>([
                SELECT Id
                    ,Name
                    ,AccountSource
                    ,Type
                    ,Website
                    FROM Account
                    WHERE Name LIKE :'%'+searchKeyword+'%' 
                    LIMIT :pageSize OFFSET :((currentPage-1) * pageSize)
            ]);
            // 统计符合条件的总记录数
            Integer totalCount = [SELECT COUNT() FROM Account WHERE Name LIKE :'%'+searchKeyword+'%'];
            Integer totalPage = (totalCount + pageSize - 1) / pageSize;
            // 封装返回的数据
            resMap.put('record', accList);
            resMap.put('totalPage', totalPage);
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return resMap;
    }

   
}
